package com.surprise.webcommon.logger;

import com.surprise.base.util.JacksonUtils;

import lombok.extern.log4j.Log4j;



/**
 * LogUtils.java
 * @author nick
 * 2015年2月10日
 */
@Log4j
public class LogUtils {
    public static String log(long time, Object req, Object res) {
        return "[index][req:" + req.toString() + "][res:" + res.toString()
                + "][time:" + time + "]";
    }
    
    public static void log(Object obj) {
        log.info(format(obj));
    }
    
    public static String format(Object obj) {
        if(obj == null) {
            return "";
        }
        String json = JacksonUtils.toJson(obj);
        return json.replaceAll("\t", "\\t").replaceAll("\n", "\\n");
    }
}
